package com.itstudy.springbootreqresp.controller;

import com.itstudy.springbootreqresp.pojo.Address;
import com.itstudy.springbootreqresp.pojo.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.itstudy.springbootreqresp.pojo.Result;

import java.util.ArrayList;
import java.util.List;

@RestController
public class ResponseController {
    @RequestMapping("hello")
    public Result hello()
    {
        System.out.println("hello world");
        return Result.success("hello world");
    }

    @RequestMapping("getArr")
    public Result getArr()
    {
        Address address = new Address();
        address.setProvince("北京");
        address.setCity("北京");
        return Result.success(address);
    }
    @RequestMapping("listArr")
    public Result listArr()
    {
        List<Address> list = new ArrayList<>();
        Address address1 = new Address();
        address1.setProvince("北京");
        address1.setCity("北京");
        Address address2 = new Address();
        address2.setProvince("上海");
        address2.setCity("上海");
        list.add(address1);
        list.add(address2);
        return Result.success(list);
    }
}
